#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QMessageBox>
#include<QToolBar>
#include<QStatusBar>
#include<QLabel>
#include<QTextEdit>
#include<QDockWidget>


MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QMenuBar *mBar = menuBar();
    QMenu *pFile =mBar->addMenu("文件");

    QAction *pNew = pFile->addAction("new file");

    connect(pNew,&QAction::triggered,[=]{
        QMessageBox::information(this,"file","new file");
    });

    pFile->addSeparator();
    pFile->addAction("open file");

    QToolBar *toolBar = addToolBar("toolBar");

    toolBar->addAction(pNew);
    QPushButton *btn = new QPushButton(this);

    btn->setText("^_^");
    btn->show();
    toolBar->addWidget(btn);

    connect(btn,&QPushButton::clicked,[=]{
       QMessageBox::information(this,"btn","smile");
    });




    QStatusBar *status = statusBar();
    status->addAction(pNew);
    QLabel *label = new QLabel(this);
    label->setText("nothing");
    status->addWidget(label);

    status->addWidget(new QLabel("Demo5",this));

    QTextEdit *textEdit = new QTextEdit(this);
    setCentralWidget(textEdit);



    QDockWidget *doc = new QDockWidget(this);

    addDockWidget(Qt::RightDockWidgetArea,doc);

    QTextEdit *textEdit2 = new QTextEdit(doc);
    doc->setWidget(textEdit2);









}

MainWindow::~MainWindow()
{
    delete ui;
}

